package com.example.appointment.mapper;

import com.example.appointment.entity.Appointment;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface AppointmentMapper {
    @Select("SELECT * FROM appointment")
    List<Appointment> findAll();

    @Select("SELECT * FROM appointment WHERE id = #{id}")
    Appointment findById(Long id);

    @Insert("INSERT INTO appointment(title, description, start_time, end_time, location, status) " +
            "VALUES(#{title}, #{description}, #{startTime}, #{endTime}, #{location}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Appointment appointment);

    @Update("UPDATE appointment SET title=#{title}, description=#{description}, " +
            "start_time=#{startTime}, end_time=#{endTime}, location=#{location}, status=#{status} " +
            "WHERE id=#{id}")
    int update(Appointment appointment);

    @Delete("DELETE FROM appointment WHERE id=#{id}")
    int delete(Long id);
}